package com.laijiale.controller;

import com.laijiale.dto.ReportInsertDTO;
import com.laijiale.dto.ReportPageDTO;
import com.laijiale.dto.ReportUpdateDTO;
import com.laijiale.entity.Report;
import com.laijiale.service.ReportService;
import com.mybatisflex.core.paginate.Page;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.laijiale.entity.Report;
import com.laijiale.service.ReportService;
import vo.ReportSimpleListVO;

import java.util.List;

/**
 * 举报表 控制层。
 *
 * @author laijiale
 * @since 2024-12-22
 */
@RestController
@RequestMapping("/report")
public class ReportController {

    @Autowired
    private com.laijiale.service.ReportService ReportService;


    @Operation(summary ="新增－ 单条",description ="新增一条举报记录")
    @PostMapping("insert")
    public boolean insert(@Validated @RequestBody ReportInsertDTO dto) {
        return ReportService.insert(dto);
    }
    @Operation(summary="查询－ 单条",description="按主键查询一条举报记录")
    @GetMapping("select/{id}")
    public Report select(@PathVariable("id") Long id) {
        return ReportService.select(id);
    }
    @Operation(summary ="查询－ 简单全查",description="查询全部举报记录")
    @GetMapping("simpleList")
    public List<ReportSimpleListVO> simpleList() {
        return ReportService.simpleList();
    }
    @Operation(summary="查询－ 分页",description ="分页查询举报记录")
    @GetMapping("page")
    public Page<Report> page(@Validated ReportPageDTO dto) {
        return ReportService.page(dto);
    }

    @Operation(summary="修改－单条",description ="按主键修改一条举报记录")
    @PutMapping("update")
    public boolean update(@RequestBody ReportUpdateDTO dto) {
        return ReportService.update(dto);
    }
    @Operation(summary="删除－ 单条",description="按主键删除一条举报记录")
    @DeleteMapping("delete/{id}")
    public boolean delete(@PathVariable("id") Long id) {
        return ReportService.delete(id);
    }
    @Operation(summary="删除－ 批量",description ="按主键批量删除举报记录")
    @DeleteMapping("deleteBatch")
    public boolean deleteBatch(@RequestParam("ids") List<Long> ids) {
        return ReportService.deleteBatch(ids);
    }

}
